package enumdemo;

import java.util.SplittableRandom;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2025-03-29
 * Time: 16:14
 */
public enum TestEnum {
    //默认继承enum类
    RED(1,"红色"),
    BLACK(2,"黑色"),
    GREEN(3,"绿色");

    private int ordinal;
    private String color;

    TestEnum(int ordinal,String color){
        this.ordinal = ordinal;
        this.color = color;
    }

    public static void main(String[] args) {
        TestEnum[] testEnums = TestEnum.values();
        for (int i = 0; i < testEnums.length; i++) {
            System.out.println(testEnums[i] + " " + testEnums[i].ordinal());
        }
        System.out.println("==========");
        TestEnum testEnum =  TestEnum.valueOf("RED");
        System.out.println(testEnum);
    }

    public static void main1(String[] args) {
        TestEnum testEnum = TestEnum.BLACK;
        switch (testEnum){
            case BLACK :
                System.out.println("black");
                break;
            case RED:
                System.out.println("red");
                break;
            case GREEN:
                System.out.println("green");
                break;
            default:
        }
    }
}
